﻿<navigation:Page xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" 
                 x:Class="VisitorsApp.Home" 
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
                 mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"  
                 xmlns:converter="clr-namespace:VisitorsApp.Helpers"                        
                 Style="{StaticResource PageStyle}">

    <navigation:Page.Resources>
        <converter:ByteConverter x:Key="ByteConverter" />
    </navigation:Page.Resources>

    <Grid x:Name="LayoutRoot">

        <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" >
            <sdk:DataGrid ItemsSource="{Binding Users}" Grid.Row="0" 
                          AutoGenerateColumns="False" IsReadOnly="True" MinWidth="150"
                          SelectedItem="{Binding CurrentUser, Mode=TwoWay}">
                <sdk:DataGrid.Columns>
                    <sdk:DataGridTextColumn Width="150" Header="User Name" Binding="{Binding UserName}"/>
                </sdk:DataGrid.Columns>
            </sdk:DataGrid>

            <sdk:DataGrid ItemsSource="{Binding Folders}" Grid.Row="0" 
                          AutoGenerateColumns="False" IsReadOnly="True" MinWidth="150"
                          SelectedItem="{Binding CurrentFolder, Mode=TwoWay}">
                <sdk:DataGrid.Columns>
                    <sdk:DataGridTextColumn Width="150" Header="User Name" Binding="{Binding FolderName}"/>
                </sdk:DataGrid.Columns>
            </sdk:DataGrid>

            <sdk:DataGrid ItemsSource="{Binding Images}" Grid.Row="0" 
                          AutoGenerateColumns="False" IsReadOnly="True" MinWidth="150"
                          SelectedItem="{Binding CurrentImage, Mode=TwoWay}">
                <sdk:DataGrid.Columns>
                    <sdk:DataGridTextColumn Width="150" Header="Picture name" Binding="{Binding ImageName}"/>
                    <sdk:DataGridTemplateColumn Header="Thumbnail">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Image Source="{Binding ImageData, Converter={StaticResource ByteConverter}}" Height="100" Width="100"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                    <sdk:DataGridTextColumn Width="150" Header="Picture Description" Binding="{Binding Description}"/>
                    <sdk:DataGridTemplateColumn Header="Thumbnail">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Button Height="20" Width="100" 
                                        HorizontalAlignment="Center" VerticalAlignment="Center" 
                                        Content="ViewDetails" Click="ButtonViewDetails_Click"/>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                </sdk:DataGrid.Columns>
            </sdk:DataGrid>

        </StackPanel>

    </Grid>

</navigation:Page>